//
//  CSectionController.m
//  BaseProject
//
//  Created by itzhaolei on 2024/5/13.
//

#import "CSectionController.h"
#import "CommonCollectionViewCell.h"

@interface CSectionController()

/// 演示数据变化
@property (nonatomic, strong) NSMutableArray *nums;

@end

@implementation CSectionController

- (instancetype)initWithCoordinator:(CommonListCoordinator<ListCoordinatorDelegate> *)coordinator {
    if (self = [super initWithCoordinator:coordinator]) {
        NSLog(@"C区行为被初始化");
        self.nums = @[@0, @0, @0, @0].mutableCopy;
        self.minimumLineSpacing = 10;
        self.minimumInteritemSpacing = 10;
        self.inset = UIEdgeInsetsMake(15, 15, 15, 15);
    }
    return self;
}

#pragma mark - Overwrite

// 当前区域内的单元格数量
- (NSInteger)numberOfItems {
    return 4;
}

// 当前区域内的单元格所占大小
- (CGSize)sizeForItemAtIndex:(NSInteger)index {
    return CGSizeMake(UIScreen.mainScreen.bounds.size.width / 2 - 20, UIScreen.mainScreen.bounds.size.width / 2 - 20);
}

// 当前区域内的单元格构建与复用
- (__kindof UICollectionViewCell *)cellForItemAtIndex:(NSInteger)index {
    CommonCollectionViewCell *cell = [self.collectionContext dequeueReusableCellOfClass:[CommonCollectionViewCell class] forSectionController:self atIndex:index];
    NSArray *list = @[
        @"C1区",
        @"C2区",
        @"C3区",
        @"C4区"
    ];
    cell.backgroundColor = UIColor.redColor;
    cell.contentLabel.text = [NSString stringWithFormat:@"%@ : %@", list[index], self.nums[index]];
    return cell;
}

@end
